import { createRouter, createWebHistory } from 'vue-router'
// import { useUserStore } from '@/stores/index.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/404',
      name: '404',
      component: () => import('@/views/error/404.vue')
    },
    {
      path: '/:pathMatch(.*)',
      name: 'notFound',
      hidden: true,
      redirect: '/404'
    },
    {
      path: '/',
      redirect: '/device',
      component: () => import('@/views/layout/index.vue'),
      children: [
        {
          path: '/device',
          name: 'Device',
          component: () => import('@/views/layout/device/index.vue')
        },
        {
          path: '/data',
          name: 'Data',
          component: () => import('@/views/layout/data/index.vue')
        }
      ]
    }
  ]
})
// const antUrls = [
//   '/song/manage',
//   '/playlist/manage',
//   '/album/manage',
//   '/comment',
//   '/type',
//   '/user/info',
//   '/user/manage'
// ]
// // const antUrls = []
// router.beforeEach(async (to) => {
//   const userStore = useUserStore()
//   // 访问需要登录的页面时
//   if (antUrls.includes(to.path) && !userStore.user.token) {
//     // 没有token直接跳转登录
//     return '/login'
//   }
//   // 无需登录的地方直接放行
//   return true
// })

export default router
